#include <iostream>
#include <vector>
#include <string>

struct subpal
{
    size_t length;
    size_t prevBegin;
    size_t prevEnd;

    subpal(size_t newLen = 0, size_t prX = 0, size_t prY = 0)
    {
        length = newLen;
        prevBegin = prX;
        prevEnd = prY;
    }
};
int main()
{
    std::string str;
    std::cin >> str;
    std::vector< std::vector<subpal> > maxl;
    maxl.resize(str.length());
    for (size_t i = 0; i < str.length(); ++i)
        maxl[i].resize(str.length());

    for (size_t i = 0; i < str.length(); ++i)
        maxl[i][i].length = 1;
    for (size_t i = 1; i < str.length(); ++i)
        for (int j = 0; j < str.length() - i; ++j)
        {
            if (str[j] != str[i + j])
            {
                if (maxl[j + 1][i + j].length < maxl[j][i + j - 1].length)
                {
                    maxl[j][i + j].length = maxl[j][i + j - 1].length;
                    maxl[j][i + j].prevBegin = j;
                    maxl[j][i + j].prevEnd = i + j - 1;
                }
                else
                {
                    maxl[j][i + j].length = maxl[j + 1][i + j].length;
                    maxl[j][i + j].prevBegin = j + 1;
                    maxl[j][i + j].prevEnd = i + j;
                }
            }
            else
            {
                maxl[j][i + j].length = maxl[j + 1][i + j - 1].length + 2;
                maxl[j][i + j].prevBegin = j + 1;
                maxl[j][i + j].prevEnd = i + j - 1;
            }
        }

    std::string ans = "";
    size_t begin = 0;
    size_t end = str.length() - 1;
    while (end > begin)
    {
        size_t tmpBeg = begin;
        size_t tmpEnd = end;
        begin = maxl[tmpBeg][tmpEnd].prevBegin;
        end = maxl[tmpBeg][tmpEnd].prevEnd;
        if (begin != tmpBeg && end != tmpEnd)
            ans+= str[tmpBeg];
    }
    ans+= str[begin];
    for (int i = (ans.length() - 2) - ans.length()%2; i >= 0; --i)
        ans+= ans[i];
    std::cout << ans << "\n";
    //std::cout << "\n" << maxl[0][str.length() - 1].length << "\n";

    return 0;
}
